package jmine.tec.batch.event.dao;

import java.util.List;

import jmine.tec.batch.event.domain.Event;
import jmine.tec.purge.api.PurgeHelper;
import jmine.tec.purge.api.Purger;
import bancosys.tec.persist.dao.BaseDAO;
import bancosys.tec.utils.date.Date;

/**
 * Classe responsavel pelo das ocorrencias do processamento.
 * 
 * @author queiroz
 */
public class EventPurger extends BaseDAO<Event> implements Purger {

    /**
     * {@inheritDoc}
     */
    public int purge(Date maxDate, int maxWindowSize) {
        List<Long> ids = PurgeHelper.getIds(this.createCriteria(), "timestamp", maxDate, maxWindowSize);
        return this.getSession().createQuery(PurgeHelper.createDeleteQuery("Event", ids)).executeUpdate();
    }

    /**
     * {@inheritDoc}
     */
    public int countItemsToPurge(Date maxDate) {
        return PurgeHelper.countItemsToPurge(this.createCriteria(), "timestamp", maxDate);
    }
}
